#include "lightingdialog.h"
#include "ui_lightingdialog.h"


#include <QDebug>


#include "model/object.h"
#include "model/regular.h"

LightingDialog::LightingDialog(Scene *scene, QWidget *parent) :
    QWidget(parent),
    ui(new Ui::LightingDialog)
{
    ui->setupUi(this);
    connect(ui->sbFLx,SIGNAL(valueChanged(double)), scene, SLOT(setLightSourceX(double)));
    connect(ui->sbFLy,SIGNAL(valueChanged(double)), scene, SLOT(setLightSourceY(double)));
    connect(ui->sbFLz,SIGNAL(valueChanged(double)), scene, SLOT(setLightSourceZ(double)));

    connect(ui->sbFLilr,SIGNAL(valueChanged(double)), scene, SLOT(setIlr(double)));
    connect(ui->sbLAilar,SIGNAL(valueChanged(double)), scene, SLOT(setIlar(double)));

    connect(ui->sbFLilg,SIGNAL(valueChanged(double)), scene, SLOT(setIlg(double)));
    connect(ui->sbLAilag,SIGNAL(valueChanged(double)), scene, SLOT(setIlag(double)));

    connect(ui->sbFLilb,SIGNAL(valueChanged(double)), scene, SLOT(setIlb(double)));
    connect(ui->sbLAilab,SIGNAL(valueChanged(double)), scene, SLOT(setIlab(double)));

    connect(ui->sbGroundKar,SIGNAL(valueChanged(double)), scene, SLOT(setGroundKar(double)));
    connect(ui->sbGroundKag,SIGNAL(valueChanged(double)), scene, SLOT(setGroundKag(double)));
    connect(ui->sbGroundKab,SIGNAL(valueChanged(double)), scene, SLOT(setGroundKab(double)));
    connect(ui->sbGroundKdr,SIGNAL(valueChanged(double)), scene, SLOT(setGroundKdr(double)));
    connect(ui->sbGroundKdg,SIGNAL(valueChanged(double)), scene, SLOT(setGroundKdg(double)));
    connect(ui->sbGroundKdb,SIGNAL(valueChanged(double)), scene, SLOT(setGroundKdb(double)));
    connect(ui->sbGroundKsr,SIGNAL(valueChanged(double)), scene, SLOT(setGroundKsr(double)));
    connect(ui->sbGroundKsg,SIGNAL(valueChanged(double)), scene, SLOT(setGroundKsg(double)));
    connect(ui->sbGroundKsb,SIGNAL(valueChanged(double)), scene, SLOT(setGroundKsb(double)));
    connect(ui->sbGroundN,SIGNAL(valueChanged(double)), scene, SLOT(setGroundN(double)));

    connect(ui->sbBallKar,SIGNAL(valueChanged(double)), scene, SLOT(setSphereKar(double)));
    connect(ui->sbBallKag,SIGNAL(valueChanged(double)), scene, SLOT(setSphereKag(double)));
    connect(ui->sbBallKab,SIGNAL(valueChanged(double)), scene, SLOT(setSphereKab(double)));
    connect(ui->sbBallKdr,SIGNAL(valueChanged(double)), scene, SLOT(setSphereKdr(double)));
    connect(ui->sbBallKdg,SIGNAL(valueChanged(double)), scene, SLOT(setSphereKdg(double)));
    connect(ui->sbBallKdb,SIGNAL(valueChanged(double)), scene, SLOT(setSphereKdb(double)));
    connect(ui->sbBallKsr,SIGNAL(valueChanged(double)), scene, SLOT(setSphereKsr(double)));
    connect(ui->sbBallKsg,SIGNAL(valueChanged(double)), scene, SLOT(setSphereKsg(double)));
    connect(ui->sbBallKsb,SIGNAL(valueChanged(double)), scene, SLOT(setSphereKsb(double)));
    connect(ui->sbBallN,SIGNAL(valueChanged(double)), scene, SLOT(setSphereN(double)));



    Scene::Light enviromentProperties = scene->getProperties();
    Lighting groundProperties = scene->getGround()->getLightProperties();
    Lighting ballProperties = scene->getSphere()->getLightProperties();

    this->ui->sbFLx->setValue(enviromentProperties.lightSource.x);
    this->ui->sbFLy->setValue(enviromentProperties.lightSource.y);
    this->ui->sbFLz->setValue(enviromentProperties.lightSource.z);

    this->ui->sbFLilr->setValue(enviromentProperties.ilr);
    this->ui->sbFLilg->setValue(enviromentProperties.ilg);
    this->ui->sbFLilb->setValue(enviromentProperties.ilb);

    this->ui->sbLAilar->setValue(enviromentProperties.ilar);
    this->ui->sbLAilag->setValue(enviromentProperties.ilag);
    this->ui->sbLAilab->setValue(enviromentProperties.ilab);

    this->ui->sbGroundKar->setValue(groundProperties.kar);
    this->ui->sbGroundKag->setValue(groundProperties.kag);
    this->ui->sbGroundKab->setValue(groundProperties.kab);
    this->ui->sbGroundKdr->setValue(groundProperties.kdr);
    this->ui->sbGroundKdg->setValue(groundProperties.kdg);
    this->ui->sbGroundKdb->setValue(groundProperties.kdb);
    this->ui->sbGroundKsr->setValue(groundProperties.ksr);
    this->ui->sbGroundKsg->setValue(groundProperties.ksg);
    this->ui->sbGroundKsb->setValue(groundProperties.ksb);
    this->ui->sbGroundN->setValue(groundProperties.n);

    this->ui->sbBallKar->setValue(ballProperties.kar);
    this->ui->sbBallKag->setValue(ballProperties.kag);
    this->ui->sbBallKab->setValue(ballProperties.kab);
    this->ui->sbBallKdr->setValue(ballProperties.kdr);
    this->ui->sbBallKdg->setValue(ballProperties.kdg);
    this->ui->sbBallKdb->setValue(ballProperties.kdb);
    this->ui->sbBallKsr->setValue(ballProperties.ksr);
    this->ui->sbBallKsg->setValue(ballProperties.ksg);
    this->ui->sbBallKsb->setValue(ballProperties.ksb);
    this->ui->sbBallN->setValue(ballProperties.n);
}

LightingDialog::~LightingDialog()
{
    delete ui;
}

void LightingDialog::updateLight() {


}

